<div class="row row-cards row-deck">
  <div class="col-12">
    <div class="card">
      <table class="table table-hover table-outline table-vcenter text-nowrap card-table">
        <thead>
          <tr>
            <th>属性名字</th>
            <th colspan="2">拥有属性值</th>
            <th class="text-center">
              <%= link_to "添加属性", new_admin_shop_category_option_type_path(@shop_category) %>
            </th>
          </tr>
        </thead>
        <tbody>
          <% @option_types.each do |option_type| %>
          <tr>
            <td>
              <div><%= option_type.name %></div>
              <div class="small text-muted">
                <%= formattime(option_type.created_at, unit: "day") %>
              </div>
            </td>
            <td style="width: 50px;">
              <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#add_option_value_dialog" data-option-type-name="<%= option_type.name %>" data-option-type-id="<%= option_type.id %>">+</button>
            </td>
            <td>
              <div class="tags">
                <% option_type.option_values.each do |option_value| %>
                  <span class="tag tag-dark">
                    <%= option_value.presentation %>
                    <%= link_to admin_option_value_path(option_value), class: "tag-addon tag-danger", method: :delete do %>
                      <i class="fe fe-x"></i>
                    <% end %>
                  </span>
                <% end %>
              </div>
            </td>
            <td class="text-center">
              <div class="item-action dropdown">
                <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
                <div class="dropdown-menu dropdown-menu-right">
                  <a href="<%= edit_admin_shop_category_option_type_path(@shop_category, option_type) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 修改 </a>
                  <%= link_to admin_shop_category_option_type_path(@shop_category, option_type), class: "dropdown-item", method: :delete do %>
                    <i class="dropdown-icon fe fe-edit-2"></i> 删除 </a>
                  <% end %>
                </div>
              </div>
            </td>
          </tr>
          <% end %>
        </tbody>
      </table>
      <div class="modal fade" id="add_option_value_dialog" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <%= form_for [:admin, OptionValue.new] do |f|%>
              <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">添加属性值</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
              </div>
              <div class="modal-body">
                <div class="form-group">
                  <label for="option-type-name" class="col-form-label">属性名字:</label>
                  <input type="text" class="form-control" id="form-option-type-name" disabled="false">
                  <%= f.hidden_field :option_type_id, id: "form-option-type-id", class: "form-control" %>
                </div>
                <div class="form-group">
                  <label for="message-text" class="col-form-label">属性值名字:</label>
                  <%= f.text_field :name, class: "form-control" %>
                </div>
                <div class="form-group">
                  <label for="message-text" class="col-form-label">属性值显示名字:</label>
                  <%= f.text_field :presentation, class: "form-control" %>
                </div>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <%= f.submit "保 存", class: "btn btn-primary" %>
              </div>
            <% end %>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>